import java.io.File;

import org.jaudiotagger.audio.AudioFile;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.AudioHeader;
import org.jaudiotagger.tag.FieldKey;
import org.jaudiotagger.tag.Tag;


public class TagReaderTestMain {

	private static final String TEST_DIR = "C:/Users/Sebastien/Desktop/Tests";
	
	public static void main(String[] args) {
		new TagReaderTestMain().run();
	}

	private void run() {
		File testFile = new File(TEST_DIR, "Brest bay.mp3");
		AudioFile f;
		try {
			f = AudioFileIO.read(testFile);
			AudioHeader audioHeader = f.getAudioHeader();
			int length = audioHeader.getTrackLength();
			System.out.println("Length = " + length + "s.");
			Tag tag = f.getTag();
			System.out.println("Title = " + tag.getFirst(FieldKey.TITLE));
			System.out.println("Artist = " + tag.getFirst(FieldKey.ARTIST));
			System.out.println("Genre = " + tag.getFirst(FieldKey.GENRE));
			
		} catch (Throwable e) {
			e.printStackTrace();
		}
	}
}
